#include <cstdio>
#include <cstring>

char a[1000100],b[1000100];

int main(){
    scanf("%s",a);
    scanf("%s",b);
    if ( strlen(a) != strlen(b) ){
        printf("NO\n");
    }
    else{
        int cnta=0;
        for (int i=0;i<strlen(a);i++){
            if (a[i] == '1'){
                cnta++;
            }
        }   //1 in a
        int cntb=0;
        for (int i=0;i<strlen(b);i++){
            if (b[i] == '0'){
                cntb++;
            }
        }    //0 in b
        
        if (cnta < strlen(a) ){
            if (cnta == 0)
            {
                if (cntb == strlen(b))  // b all is 0
                    printf("YES\n");
                else
                    printf("NO\n");
            }
            else{
                if (cntb == strlen(b))
                    printf("NO\n");
                else
                    printf("YES\n");
            }
        }   //not all 1
        if (cnta == strlen(a) ){
            if (cntb == strlen(b) ){
                printf("NO\n");
            }
            else
                printf("YES\n");
        }
    }
}